package com.wp.controller;

import com.wp.pojo.Blog;
import com.wp.pojo.PageResult;
import com.wp.pojo.basePojo.SysResult;
import com.wp.service.BlogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/blog")
@CrossOrigin
public class BlogController {
    @Autowired
    private BlogService blogService;
    /**
     * 博客发布
     * */
    @PostMapping("/isPublish")
    public SysResult isPublishBlog(@RequestBody Blog blog){
        blogService.isPublishBlog(blog);
        return SysResult.success();
    }
    /**
     * 博客删除
     * */
    @PostMapping("/updateStatus")
    public SysResult updateStatusBlog(@RequestBody Blog blog){
        blogService.updateStatus(blog);
        return SysResult.success();
    }
    /**
     * 获取博客列表
     * */
    @GetMapping("/getList")
    public SysResult getBlogList(PageResult pageResult){
        PageResult pageResults = blogService.getBlogList(pageResult);
        return SysResult.success(pageResults);
    }
    /**
     * 增加博客
     * */
    @PostMapping("/add")
    public SysResult addBlog(@RequestBody Blog blog){
        blogService.addBlog(blog);
        return SysResult.success();

    }
    /**
     * 编辑博客
     * */
    @PostMapping("/edit")
    public SysResult editBlog(@RequestBody Blog blog){
        blogService.editBlog(blog);
        return SysResult.success();
    }
    /**
     * 标题图和博客内容图上传
     * */
//    @PostMapping("/uploadImage")
//    public SysResult uploadImage(@RequestBody MultipartFile file){
//
//    }
}

